//
//  WYInnerVC.m
//  Brand
//
//  Created by Faker on 5/29/14.
//  Copyright (c) 2014 Faker. All rights reserved.
//

#import "WYInnerVC.h"
#import "Header.h"

@interface WYInnerVC ()

@property (weak, nonatomic) IBOutlet UIImageView *personBgImageView;
@property (weak, nonatomic) IBOutlet UIImageView *personImageView;
@property (weak, nonatomic) IBOutlet UILabel *infoLabel1;
@property (weak, nonatomic) IBOutlet UILabel *infoLabel2;

@end

@implementation WYInnerVC

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setUp];
}

-(void)setUp
{
    self.infoLabel1.text = [NSString stringWithFormat:@"%@--%@",self.level.type,self.level.name];
    self.infoLabel2.text = self.level.reason;
    [self startAnimation];
    [[AFGetData sharedInstance] initSDWebImage:self.level.picUrl andTrueImageView:self.personImageView andPlaceholderImage:nil];
    [kApp initShareViewWithUrl:ShareUrl andWithTitle:ShareTitle andWithInfo:NotifyGetWYShare(self.level.name) andWithImageUlr:self.level.picUrl andIsSuccess:^(BOOL isSuccess) {
        if(isSuccess)
        {
            [PopTips tips:kApp.rootNav.view Msg:NotifyShareSuccess];
        }
        else{
            [PopTips tips:kApp.rootNav.view Msg:NotifyShareError];
        }
    }];
}

#pragma mark - 动画
-(void)startAnimation
{
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI];
    rotationAnimation.duration = 8;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = CGFLOAT_MAX;
    rotationAnimation.removedOnCompletion = NO;
    [self.personBgImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

- (IBAction)goBack:(id)sender {
    [kApp hideWaitView];
    [[AFGetData sharedInstance] removeAllGetAndPostRequest];
    
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)goToShare:(id)sender {
    NSLog(@"picUrl1 = %@",self.level.picUrl);
    [kApp initShareViewWithUrl:ShareUrl andWithTitle:ShareTitle andWithInfo:NotifyGetWYShare(self.level.name) andWithImageUlr:self.level.picUrl andIsSuccess:^(BOOL isSuccess) {
        if(isSuccess)
        {
            [PopTips tips:kApp.rootNav.view Msg:NotifyShareSuccess];
        }
        else{
            [PopTips tips:kApp.rootNav.view Msg:NotifyShareError];
        }
    }];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
